﻿@{
    ViewBag.Title = "Craft";
}

<div class="easyui-layout" style="width:inherit;height:inherit">
    <div data-options="region:'west',split:true" style="width:200px;">
        <table id="dg" title="套餐工艺" class="easyui-datagrid" style="width:inherit;height:inherit"
                url=""
                toolbar="#toolbar"
                rownumbers="true" fitColumns="true" singleSelect="true">
            <thead>
                <tr>
                    <th field="NAME" width="50">工艺类型</th>
                </tr>
            </thead>
        </table>
        <div id="toolbar">
            <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newCraft()">添加</a>
            <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editCraft()">编辑</a>
            <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="destroyCraft()">删除</a>
        </div>
    
        <div id="dlg" class="easyui-dialog" style="width:400px;height:280px;padding:10px 20px"
                closed="true" buttons="#dlg-buttons">
            <div class="ftitle">新增工艺类型</div>
            <form id="fm" method="post" novalidate>
                <div class="fitem">
                    <label>工艺类型:</label>
                    <input name="craftname" class="easyui-validatebox" required="true">
                </div>
            </form>
        </div>
        <div id="dlg-buttons">
            <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onclick="saveCraft()">Save</a>
            <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')">Cancel</a>
        </div>
    </div>
    <div data-options="region:'center',title:'工艺配置项',iconCls:'icon-ok'">
        <div id="dlg-buttons" style="padding:5px;">
            <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" onclick="newCraft()">添加</a>
        </div>
        <div id="p" class="easyui-panel" style="width:inherit;height:320px;padding:10px; margin:5px;">
            <table style="width:inherit;">
                <tr>
                    <td>
                        <div class="fitem">
                            <label>普通名称:</label>
                            <input name="craftname" class="easyui-validatebox">
                        </div>
                    </td>
                    <td>
                        <div class="fitem">
                            <label>实创名称:</label>
                            <input name="craftname" class="easyui-validatebox">
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <div class="fitem">
                            <label>普通描述:</label>
                            <input name="craftname" class="easyui-validatebox">
                        </div>
                    </td>
                    <td>
                        <div class="fitem">
                            <label>实创描述:</label>
                            <input name="craftname" class="easyui-validatebox">
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <div class="fitem">
                            <label>普通图片:</label>
                            <img style="width:150px;height:150px;" />
                            <a href="javascript:void(0)" class="easyui-linkbutton" onclick="">浏览</a>
                        </div>
                    </td>
                    <td>
                        <div class="fitem">
                            <label>实创图片:</label>
                            <img style="width:150px;height:150px;" />
                            <a href="javascript:void(0)" class="easyui-linkbutton" onclick="">浏览</a>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                       
                    </td>
                    <td>
                        <div class="fitem" style="text-align:right;">
                            <a href="javascript:void(0)" iconCls="icon-cancel" class="easyui-linkbutton" onclick="">删除</a>
                        </div>
                    </td>
                </tr>
            </table>
        </div>
        <div id="p" class="easyui-panel" style="width:inherit;height:320px;padding:10px; margin:5px;">
            <table style="width:inherit;">
                <tr>
                    <td>
                        <div class="fitem">
                            <label>普通名称:</label>
                            <input name="craftname" class="easyui-validatebox">
                        </div>
                    </td>
                    <td>
                        <div class="fitem">
                            <label>实创名称:</label>
                            <input name="craftname" class="easyui-validatebox">
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <div class="fitem">
                            <label>普通描述:</label>
                            <input name="craftname" class="easyui-validatebox">
                        </div>
                    </td>
                    <td>
                        <div class="fitem">
                            <label>实创描述:</label>
                            <input name="craftname" class="easyui-validatebox">
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <div class="fitem">
                            <label>普通图片:</label>
                            <img style="width:150px;height:150px;" />
                            <a href="javascript:void(0)" class="easyui-linkbutton" onclick="">浏览</a>
                        </div>
                    </td>
                    <td>
                        <div class="fitem">
                            <label>实创图片:</label>
                            <img style="width:150px;height:150px;" />
                            <a href="javascript:void(0)" class="easyui-linkbutton" onclick="">浏览</a>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                       
                    </td>
                    <td>
                        <div class="fitem" style="text-align:right;">
                            <a href="javascript:void(0)" iconCls="icon-cancel" class="easyui-linkbutton" onclick="">删除</a>
                        </div>
                    </td>
                </tr>
            </table>
        </div>
        <div id="p" class="easyui-panel" style="width:inherit;height:320px;padding:10px; margin:5px;">
            <table style="width:inherit;">
                <tr>
                    <td>
                        <div class="fitem">
                            <label>普通名称:</label>
                            <input name="craftname" class="easyui-validatebox">
                        </div>
                    </td>
                    <td>
                        <div class="fitem">
                            <label>实创名称:</label>
                            <input name="craftname" class="easyui-validatebox">
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <div class="fitem">
                            <label>普通描述:</label>
                            <input name="craftname" class="easyui-validatebox">
                        </div>
                    </td>
                    <td>
                        <div class="fitem">
                            <label>实创描述:</label>
                            <input name="craftname" class="easyui-validatebox">
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <div class="fitem">
                            <label>普通图片:</label>
                            <img style="width:150px;height:150px;" />
                            <a href="javascript:void(0)" class="easyui-linkbutton" onclick="">浏览</a>
                        </div>
                    </td>
                    <td>
                        <div class="fitem">
                            <label>实创图片:</label>
                            <img style="width:150px;height:150px;" />
                            <a href="javascript:void(0)" class="easyui-linkbutton" onclick="">浏览</a>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                       
                    </td>
                    <td>
                        <div class="fitem" style="text-align:right;">
                            <a href="javascript:void(0)" iconCls="icon-cancel" class="easyui-linkbutton" onclick="">删除</a>
                        </div>
                    </td>
                </tr>
            </table>
        </div>
    </div>
</div>

 
<script type="text/javascript">
    var url;
    function newCraft(){
        $('#dlg').dialog('open').dialog('setTitle','新增工艺');
        $('#fm').form('clear');
        url = 'save_user.php';
    }
    function editCraft(){
        var row = $('#dg').datagrid('getSelected');
        if (row){
            $('#dlg').dialog('open').dialog('setTitle','编辑工艺');
            $('#fm').form('load',row);
            url = 'update_user.php?id='+row.id;
        }
    }
    function saveCraft(){
        $('#fm').form('submit',{
            url: url,
            onSubmit: function(){
                return $(this).form('validate');
            },
            success: function(result){
                var result = eval('('+result+')');
                if (result.errorMsg){
                    $.messager.show({
                        title: 'Error',
                        msg: result.errorMsg
                    });
                } else {
                    $('#dlg').dialog('close');        // close the dialog
                    $('#dg').datagrid('reload');    // reload the user data
                }
            }
        });
    }
    function destroyCraft(){
        var row = $('#dg').datagrid('getSelected');
        if (row){
            $.messager.confirm('Confirm','Are you sure you want to destroy this user?',function(r){
                if (r){
                    $.post('destroy_user.php',{id:row.id},function(result){
                        if (result.success){
                            $('#dg').datagrid('reload');    // reload the user data
                        } else {
                            $.messager.show({    // show error message
                                title: 'Error',
                                msg: result.errorMsg
                            });
                        }
                    },'json');
                }
            });
        }
    }



    function newCraftItem() {
        $('#dlg2').dialog('open').dialog('setTitle', '新增工艺项');
        $('#fm1').form('clear');
        url = 'save_user.php';
    }
</script>
<style type="text/css">
    #fm{
        margin:0;
        padding:10px 30px;
    }
    .ftitle{
        font-size:14px;
        font-weight:bold;
        padding:5px 0;
        margin-bottom:10px;
        border-bottom:1px solid #ccc;
    }
    .fitem{
        margin-bottom:5px;
    }
    .fitem label{
        display:inline-block;
        width:80px;
    }
</style>
